#import "StoryTableData.h"

@implementation StoryTableData
// The data-source protocol methods
- (int)numberOfRowsInTableView:(NSTableView *)aTable
{
	return ([storyBuffer count]);
}

- (id)tableView:(NSTableView *)aTable 
objectValueForColumn:(NSTableColumn *)aCol 
			row:(int)aRow
{
	id     loc_id, loc_dat;
	if([[aCol identifier] isEqualToString:@"Title"])
	{
		loc_dat = [titleBuffer objectAtIndex:aRow];
	}
	else if([[aCol identifier] isEqualToString:@"Author"])
	{
		loc_dat = [titleBuffer objectAtIndex:aRow];
	}

	/*NSArray          *loc_col;
	
	loc_id = [aCol identifier];
	if (loc_id != nil)
	{
		loc_col = [aBuffer objectForKey:loc_id];
		if (loc_col != nil)
		{
			loc_dat = [loc_col objectAtIndex:aRow];
		}
	}*/
	return (loc_dat);
}
-(id)init
{
	self = [super init];
	titleBuffer = [[NSMutableArray alloc] init];
	AuthorBuffer = [[NSMutableArray alloc] init];
	storyBuffer = [[NSMutableArray alloc] init];
	return self;
}
-(void)addStory:(NSString *)story withTitle:(NSString *)title withAuthor:(NSString *)author
{
	[titleBuffer addObject:title];
	[AuthorBuffer addObject:author];
}
-(IBAction)addRandom
{
	[self addStory:@"blah" withTitle:@"aaaa" withAuthor:@"blahblah"];
}
// -- additional code to initialize, access, and 
// -- modify the data buffer
// -- ...
@end
